package com.sip.stream.utils.zfy.camera;

import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.os.SystemClock;
import android.util.Log;
import android.util.Range;
import android.util.Size;

import com.gosuncn.zfyluancher.ZFYLauncherJNI;
import com.sip.stream.R;
import com.sip.stream.media.ZFYCameraParameters;
import com.sip.stream.media.ZFYMediaManager;
import com.sip.stream.utils.zfy.config.ZFYMediaConfig;
import com.sip.stream.utils.zfy.yuv.YUVToolFactory;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.SchedulerSupport;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.subjects.BehaviorSubject;
import io.reactivex.subjects.PublishSubject;

import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import kotlinx.coroutines.DebugKt;

public class ZFYCamera1Helper extends AbstractZFYCamera {
    private static final String TAG = "ZFYCamera1Helper";

    private Handler backgroundHandler;
    private HandlerThread backgroundThread;
    private int cacheCameraId;
    private ZFYCameraStatus cacheCameraStatus;
    private Camera camera;
    private CompositeDisposable compositeDisposable;
    private WeakReference<Context> contextWeakReference;
    private int flashMode;
    private AtomicInteger fpsCounter;
    private Disposable fpsCounterDisposable;
    private float maxZoom;
    private AtomicBoolean needCaptrue;
    private PublishSubject<byte[]> onPreviewFrameSubject;
    private AtomicBoolean openLock;
    private Disposable previewFrameDisposable;
    private int remoteFrameFilterCounter;
    private ZFYCameraStatus status;
    private BehaviorSubject<Boolean> takePictureBehaviorSubject;
    private int videoFrameFilterCounter;
    private Size videoSize;

    @Override
    public boolean isLocked() {
        return false;
    }

    static int access$1008(ZFYCamera1Helper zFYCamera1Helper) {
        int i = zFYCamera1Helper.videoFrameFilterCounter;
        zFYCamera1Helper.videoFrameFilterCounter = i + 1;
        return i;
    }

    static int access$1108(ZFYCamera1Helper zFYCamera1Helper) {
        int i = zFYCamera1Helper.remoteFrameFilterCounter;
        zFYCamera1Helper.remoteFrameFilterCounter = i + 1;
        return i;
    }

    public ZFYCamera1Helper(Context context) {
        this.status = new ZFYCameraStatus();
        this.needCaptrue = new AtomicBoolean();
        this.compositeDisposable = null;
        this.maxZoom = 8.0f;
        this.openLock = new AtomicBoolean();
        this.flashMode = 0;
        this.takePictureBehaviorSubject = null;
        this.fpsCounter = new AtomicInteger();
        this.videoFrameFilterCounter = 0;
        this.remoteFrameFilterCounter = 0;
        this.previewFrameDisposable = null;
        this.cacheCameraStatus = null;
        this.contextWeakReference = new WeakReference<>(context);
    }

    public ZFYCamera1Helper(Context context, int i) {
        this.status = new ZFYCameraStatus();
        this.needCaptrue = new AtomicBoolean();
        this.compositeDisposable = null;
        this.maxZoom = 8.0f;
        this.openLock = new AtomicBoolean();
        this.flashMode = 0;
        this.takePictureBehaviorSubject = null;
        this.fpsCounter = new AtomicInteger();
        this.videoFrameFilterCounter = 0;
        this.remoteFrameFilterCounter = 0;
        this.previewFrameDisposable = null;
        this.cacheCameraStatus = null;
        this.contextWeakReference = new WeakReference<>(context);
        this.flashMode = i;
    }


    private void updateCameraStatusWhenInfraredLight() {
        Log.i(TAG, "updateCameraStatusWhenInfraredLight");
        if (needReopenCamera()) {
            Log.i(TAG, "needReopenCamera");
            Camera camera = this.camera;
            if (camera != null) {
                try {
                    camera.setPreviewCallback(null);
                    this.camera.stopPreview();
                    this.camera.release();
                } catch (Exception unused) {
                }
                this.camera = null;
            }
            updateCameraStream(this.status.isPreviewing(), this.status.isRecording(), this.status.isRemoteing());
        } else if (this.camera != null) {
            try {
                Camera.Parameters parameters2 = this.camera.getParameters();
                parameters2.setColorEffect(SchedulerSupport.NONE);
                this.camera.setParameters(parameters2);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private synchronized Handler getBackgroundHandler() {
        if (this.backgroundThread == null || this.backgroundHandler == null) {
            HandlerThread handlerThread = new HandlerThread("CameraBackground");
            this.backgroundThread = handlerThread;
            handlerThread.start();
            this.backgroundHandler = new Handler(this.backgroundThread.getLooper(), new Handler.Callback() {
                @Override
                public boolean handleMessage(Message message) {
                    return false;
                }
            });
        }
        return this.backgroundHandler;
    }

    @Override
    public Single<Boolean> capture() {
        Log.i(TAG, "capture");
        if (this.camera == null) {
            Log.i(TAG, "capture when camera == null");
            updateCameraStream(true, false, false);
            Single.timer(1500L, TimeUnit.MILLISECONDS).subscribe(new SingleObserver<Long>() {
                @Override
                public void onError(Throwable th) {
                }

                @Override
                public void onSubscribe(Disposable disposable) {
                }

                @Override
                public void onSuccess(Long l) {
                    if (ZFYCamera1Helper.this.camera != null) {
                        ZFYCamera1Helper.this.camera.takePicture(null, null, new Camera.PictureCallback() {
                            @Override
                            public void onPictureTaken(byte[] bArr, Camera camera) {
                                Log.i(ZFYCamera1Helper.TAG, "jpeg length" + bArr.length);
                                ZFYCamera1Helper.this.onCaptureComplete(bArr, 256);
                                camera.startPreview();
                            }
                        });
                    }
                }
            });
            return Single.just(Boolean.TRUE);
        } else if (this.status.isRecording() || this.status.isRemoteing()) {
            Log.i(TAG, "capture when streaming");
            return Single.just(Boolean.TRUE);
        } else {
            Log.i(TAG, "camera.takePicture");
            this.takePictureBehaviorSubject = BehaviorSubject.create();
            this.camera.takePicture(null, null, new Camera.PictureCallback() {
                @Override
                public void onPictureTaken(byte[] bArr, Camera camera) {
                    Log.i(ZFYCamera1Helper.TAG, "jpeg length" + bArr.length);
                    ZFYCamera1Helper.this.onCaptureComplete(bArr, 256);
                    if (ZFYCamera1Helper.this.takePictureBehaviorSubject != null) {
                        ZFYCamera1Helper.this.takePictureBehaviorSubject.onNext(Boolean.TRUE);
                    }
                    camera.startPreview();
                }
            });
            return this.takePictureBehaviorSubject.firstOrError().doFinally(new Action() {
                @Override
                public void run() {
                    ZFYCamera1Helper.this.takePictureBehaviorSubject = null;
                }
            });
        }
    }


    private Context getContext() {
        return this.contextWeakReference.get();
    }

    private boolean needReopenCamera() {
        int camereaId;
        return (this.camera == null || (camereaId = getCamereaId()) < 0 || camereaId == this.cacheCameraId) ? false : true;
    }

    private int getCamereaId() {
        return cacheCameraId;
    }

    @Override
    public void updateCameraStream(boolean isPreviewing, boolean isRecording, boolean isRemoting) {
        if (this.openLock.get()) {
            Log.e(TAG, "openLock.get() true");
            ZFYCameraStatus zFYCameraStatus = new ZFYCameraStatus();
            this.cacheCameraStatus = zFYCameraStatus;
            zFYCameraStatus.setPreviewing(isPreviewing);
            this.cacheCameraStatus.setRecording(isRecording);
            this.cacheCameraStatus.setRemoteing(isRemoting);
            return;
        }
        this.openLock.set(true);
        try {
            if (updateCameraStream_t(isPreviewing, isRecording, isRemoting)) {
                return;
            }
            this.openLock.set(false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean updateCameraStream_t(boolean isPreviewing, boolean isRecording, boolean isRemoting) throws Exception {
        if (isPreviewing || isRecording || isRemoting) {
            Log.i(TAG, "updateCameraStream_t");
            this.status.setRecording(isRecording);
            this.status.setRemoteing(isRemoting);
            this.status.setPreviewing(isPreviewing);
            if (getContext() == null) {
                return false;
            }
            if (this.camera != null) {
                Log.w(TAG, "camera != null");
                return false;
            }
            int camereaId = getCamereaId();
            if (camereaId < 0) {
                return false;
            }
            Camera open = Camera.open(camereaId);
            this.cacheCameraId = camereaId;
            Log.i(TAG, "set cacheCameraId " + this.cacheCameraId);
            Camera.Parameters parameters = open.getParameters();
            Camera.Size selectFrontCamreaSize = this.frontSide ? selectFrontCamreaSize(open) : selectBackCamreaSize(open);
            open.setPreviewTexture(getPreviewSurfaceTexture());
            parameters.setPreviewFormat(17);
            parameters.setPreviewSize(selectFrontCamreaSize.width, selectFrontCamreaSize.height);
            parameters.setPictureFormat(256);
            setCamera1PictureSize(parameters, selectFrontCamreaSize);
            parameters.setJpegQuality(20);
            Log.i(TAG, "bufferSize: " + (((selectFrontCamreaSize.width * selectFrontCamreaSize.height) * ImageFormat.getBitsPerPixel(17)) / 8));
            open.setPreviewCallback(new Camera.PreviewCallback() {
                @Override
                public void onPreviewFrame(byte[] bArr, Camera camera) {
                    if (bArr == null) {
                        Log.e(TAG, "bytes = null");
                        return;
                    }
                    byte[] obtainOutputData = YUVToolFactory.obtainOutputData(bArr.length);
                    System.arraycopy(bArr, 0, obtainOutputData, 0, bArr.length);
                    if (ZFYCamera1Helper.this.onPreviewFrameSubject != null) {
                        ZFYCamera1Helper.this.onPreviewFrameSubject.onNext(obtainOutputData);
                    } else {
                        Log.w(ZFYCamera1Helper.TAG, "onPreviewFrameSubject = null");
                    }
                }
            });
            setUpPreviewFrame();
            this.maxZoom = open.getParameters().getMaxZoom();
            if (!this.frontSide) {
                setUpFPS(parameters);
                parameters.setVideoStabilization(this.stabilization);
            } else {
                parameters.setPreviewFpsRange(30000, 30000);
            }
            if (this.currentZoom > 1.0f) {
                float f = this.currentZoom;
                float f2 = this.maxZoom;
                if (f > f2) {
                    this.currentZoom = f2;
                }
                parameters.setZoom((int) this.currentZoom);
                Log.i(TAG, " parameters.setZoom where create: " + this.currentZoom);
            }
            if (this.flashMode == 1) {
                parameters.setFlashMode("torch");
            } else {
                parameters.setFlashMode(DebugKt.DEBUG_PROPERTY_VALUE_OFF);
            }
            try {
                open.setParameters(parameters);
            } catch (Exception e) {
                Log.e(TAG, "" + e.getMessage());
                e.printStackTrace();
            }
            open.startPreview();
            this.camera = open;
            Single.timer(100L, TimeUnit.MILLISECONDS).subscribe(new SingleObserver<Long>() {
                @Override
                public void onError(Throwable th) {
                }

                @Override
                public void onSubscribe(Disposable disposable) {
                }

                @Override
                public void onSuccess(Long l) {
                    ZFYCamera1Helper.this.checkStatus();
                }
            });
            return true;
        }
        return false;
    }

    public void setCamera1PictureSize(Camera.Parameters parameters, Camera.Size size) {
        Camera.Size size2;
        Iterator<Camera.Size> it = parameters.getSupportedPreviewSizes().iterator();
        while (true) {
            if (!it.hasNext()) {
                size2 = null;
                break;
            }
            size2 = it.next();
            Log.i(TAG, "setCamera1PictureSize width: " + size2.width + " x height: " + size2.height);
            if (Math.abs((size2.height / size2.width) - 0.5625f) < 0.01f) {
                break;
            }
        }
        if (size2 == null) {
            Log.w(TAG, "not found size");
        } else {
            parameters.setPictureSize(size2.width, size2.height);
        }
    }

    private void startFPSCounter() {
        Disposable disposable = this.fpsCounterDisposable;
        if (disposable != null) {
            disposable.dispose();
            this.fpsCounterDisposable = null;
        }
        Observable.interval(1L, TimeUnit.SECONDS).subscribe(new Observer<Long>() {
            @Override
            public void onComplete() {
            }

            @Override
            public void onError(Throwable th) {
            }

            @Override
            public void onSubscribe(Disposable disposable2) {
                ZFYCamera1Helper.this.fpsCounterDisposable = disposable2;
            }

            @Override
            public void onNext(Long l) {
                Log.i(ZFYCamera1Helper.TAG, "fpsCounter = " + ZFYCamera1Helper.this.fpsCounter);
                ZFYCamera1Helper.this.fpsCounter.set(0);
            }
        });
    }

    private void stopFPSCounter() {
        Disposable disposable = this.fpsCounterDisposable;
        if (disposable != null) {
            disposable.dispose();
            this.fpsCounterDisposable = null;
        }
    }

    public void setUpFPS(Camera.Parameters parameters) {
        int i;
        int cameraFPSRange = ZFYMediaManager.getInstance().getConfig().getVideoFPS();
        int cameraFPSRange2 = ZFYMediaManager.getInstance().getConfig().getStreamFPS();
        if (cameraFPSRange2 > cameraFPSRange) {
            cameraFPSRange2 = cameraFPSRange;
        }
        Range range = new Range(Integer.valueOf(cameraFPSRange), Integer.valueOf(cameraFPSRange));
        String str = TAG;
        Log.i(str, "cameraFPS: " + cameraFPSRange + " videoFPS: " + cameraFPSRange + " streamFPS: " + cameraFPSRange2);
        Log.d(str, "setPreviewFpsRange(" + (((Integer) range.getLower()).intValue() * 1000) + ", " + (((Integer) range.getUpper()).intValue() * 1000) + ")");
        parameters.setPreviewFpsRange(((Integer) range.getLower()).intValue() * 1000, ((Integer) range.getUpper()).intValue() * 1000);
        if (cameraFPSRange2 <= cameraFPSRange / 2) {
            i = -(cameraFPSRange / cameraFPSRange2);
        } else {
            i = cameraFPSRange2 == cameraFPSRange ? 0 : cameraFPSRange / ((cameraFPSRange - cameraFPSRange2) + 1);
        }
        this.status.setVideoFrameFilter(0);
        this.status.setStreamFrameFilter(i);
        Log.i(str, "set frame filter local: " + this.status.getVideoFrameFilter() + " stream: " + this.status.getStreamFrameFilter());
    }

    private void setUpPreviewFrame() {
        Log.i(TAG, "setUpPreviewFrame");
        Disposable disposable = this.previewFrameDisposable;
        if (disposable != null) {
            disposable.dispose();
            this.previewFrameDisposable = null;
        }
        PublishSubject<byte[]> create = PublishSubject.create();
        this.onPreviewFrameSubject = create;
        create.subscribeOn(AndroidSchedulers.from(getBackgroundHandler().getLooper())).subscribe(new Observer<byte[]>() {
            @Override
            public void onComplete() {
            }

            @Override
            public void onSubscribe(Disposable disposable2) {
                ZFYCamera1Helper.this.previewFrameDisposable = disposable2;
            }

            @Override
            public void onNext(byte[] bArr) {
                ZFYCamera1Helper.this.fpsCounter.getAndAdd(1);
                if (ZFYCamera1Helper.this.status.isRecording() || ZFYCamera1Helper.this.status.isRemoteing())
                {
                    if (ZFYLauncherJNI.NV12ToNV21(bArr, bArr, ZFYCamera1Helper.this.videoSize.getWidth(), ZFYCamera1Helper.this.videoSize.getHeight()) == 0)
                    {
                        if (ZFYCamera1Helper.this.status.isRecording())
                        {
                            if (ZFYCamera1Helper.this.status.getVideoFrameFilter() > 0)
                            {
                                if (ZFYCamera1Helper.this.videoFrameFilterCounter > ZFYCamera1Helper.this.status.getVideoFrameFilter())
                                {
                                    ZFYCamera1Helper.this.videoFrameFilterCounter = 1;
                                    return;
                                }
                                ZFYCamera1Helper.access$1008(ZFYCamera1Helper.this);
                            }
                            ZFYCamera1Helper.this.onVideoStream(bArr, SystemClock.elapsedRealtimeNanos() / 1000);
                        }

                        if (ZFYCamera1Helper.this.status.getStreamFrameFilter() > 0)
                        {
                            if (ZFYCamera1Helper.this.remoteFrameFilterCounter > ZFYCamera1Helper.this.status.getStreamFrameFilter()) {
                                ZFYCamera1Helper.this.remoteFrameFilterCounter = 1;
                                return;
                            }
                            ZFYCamera1Helper.access$1108(ZFYCamera1Helper.this);
                        } else if (ZFYCamera1Helper.this.status.getStreamFrameFilter() < 0)
                        {
                            if (ZFYCamera1Helper.this.remoteFrameFilterCounter >= 0 - ZFYCamera1Helper.this.status.getStreamFrameFilter())
                            {
                                ZFYCamera1Helper.this.remoteFrameFilterCounter = 1;
                            } else {
                                ZFYCamera1Helper.access$1108(ZFYCamera1Helper.this);
                                return;
                            }
                        }


                        if (ZFYCamera1Helper.this.status.isRemoteing()) {
                            byte[] obtainOutputData = YUVToolFactory.obtainOutputData(bArr.length);
                            System.arraycopy(bArr, 0, obtainOutputData, 0, bArr.length);
                            ZFYCamera1Helper.this.onRemoteStream(obtainOutputData, SystemClock.elapsedRealtimeNanos() / 1000);
                            return;
                        }
                        return;
                    }
                    YUVToolFactory.recycleData(bArr);
                }
            }

            @Override
            public void onError(Throwable th) {
                th.printStackTrace();
            }
        });
    }

    @Override
    public float getMaxZoomValue() {
        return this.maxZoom;
    }

    @Override
    public boolean setFlashMode(int flashMode) {
        this.flashMode = flashMode;
        if (this.camera == null || this.openLock.get()) {
            return true;
        }
        try {
            Camera.Parameters parameters = this.camera.getParameters();
            if (this.flashMode == 1) {
                parameters.setFlashMode("torch");
            } else {
                parameters.setFlashMode(DebugKt.DEBUG_PROPERTY_VALUE_OFF);
            }
            this.camera.setParameters(parameters);
            updatePreviewStatus();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public Single<Boolean> closeCamera() {
        Log.i(TAG, "closeCamera");
        this.openLock.set(true);
        if (camera != null) {
            try {
                camera.setPreviewCallback(null);
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                this.camera.stopPreview();
                this.camera.release();
                this.camera = null;
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        if (this.previewFrameDisposable != null) {
            this.previewFrameDisposable.dispose();
            this.previewFrameDisposable = null;
        }
        stopFPSCounter();
        this.openLock.set(false);
        return Single.just(Boolean.TRUE);
    }

    @Override
    public String getLocalizedName() {
        return getContext().getString(R.string.camera_name_build_int);
    }

    @Override
    public void setInfraredLightMode(boolean z) {
    }

    @Override
    public void changeInfraredLight(boolean z) {
    }

    @Override
    public Observable<ZFYCameraParameters> changePPI() {
        return Observable.just(ZFYMediaManager.getInstance().getCameraParameters());
    }

    @Override
    public void switchInfraredLight() {
    }

    @Override
    public Single<ZFYCameraParameters> setUp() {
        return Single.just(this.cameraParameters);
    }

    @Override
    public void setCurrentZoom(float zoom) {
        this.currentZoom = zoom;
        Log.i(TAG, "currentZoom: " + this.currentZoom);
        if (this.camera != null) {
            super.setCurrentZoom(zoom);
            Camera.Parameters parameters = this.camera.getParameters();
            parameters.setZoom((int) this.currentZoom);
            this.camera.setParameters(parameters);
            updatePreviewStatus();
        }
    }

    private Camera.Size selectBackCamreaSize(Camera camera) {
        ZFYMediaConfig config = ZFYMediaManager.getInstance().getConfig();
        Iterator<Camera.Size> it = camera.getParameters().getSupportedPreviewSizes().iterator();
        Camera.Size size = null;
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Camera.Size next = it.next();
            Log.i(TAG, "width: " + next.width + " x height: " + next.height);
            if (next.height == config.getVideoHeight() && next.width == config.getVideoWidth()) {
                size = next;
                break;
            } else if (size == null && Math.abs((next.height / next.width) - 0.5625f) < 0.01f) {
                size = next;
            }
        }
        Log.i(TAG, "selectSize width" + size.width + " x height: " + size.height);
        this.videoSize = new Size(size.width, size.height);
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setVideoWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setVideoHeight(this.videoSize.getHeight());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setCaptrueHeight(this.videoSize.getHeight());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setCaptrueWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setRemoteWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setRemoteHeight(this.videoSize.getHeight());
        return size;
    }

    private Camera.Size selectFrontCamreaSize(Camera camera) {
        float f = 1080 / 1920;
        camera.setDisplayOrientation(90);
        Iterator<Camera.Size> it = camera.getParameters().getSupportedPreviewSizes().iterator();
        Camera.Size size = null;
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Camera.Size next = it.next();
            Log.i(TAG, "width: " + next.width + " x height: " + next.height);
            if (next.height == 1080 && next.width == 1920) {
                size = next;
                break;
            } else if (size == null && Math.abs((next.height / next.width) - f) < 0.01f) {
                size = next;
            }
        }
        Log.i(TAG, "selectSize width" + size.width + " x height: " + size.height);
        this.videoSize = new Size(size.width, size.height);
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setVideoWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setVideoHeight(this.videoSize.getHeight());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setCaptrueHeight(this.videoSize.getHeight());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setCaptrueWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setRemoteWidth(this.videoSize.getWidth());
        ZFYMediaManager.getInstance().getStatus().getCameraParameters().setRemoteHeight(this.videoSize.getHeight());
        return size;
    }

    public synchronized void checkStatus() {
        ZFYCameraStatus zFYCameraStatus = this.cacheCameraStatus;
        if (zFYCameraStatus != null) {
            this.cacheCameraStatus = null;
            Log.e(TAG, "check status " + this.status.toString() + " " + zFYCameraStatus.toString());
            if (zFYCameraStatus.isRemoteing() != this.status.isRemoteing() || zFYCameraStatus.isRecording() != this.status.isRecording()) {
                Log.e(TAG, "check status need updateCameraStream");
                Single.just(zFYCameraStatus).delay(300L, TimeUnit.MILLISECONDS).subscribe(new SingleObserver<ZFYCameraStatus>() {
                    @Override
                    public void onError(Throwable th) {
                    }

                    @Override
                    public void onSubscribe(Disposable disposable) {
                    }

                    @Override
                    public void onSuccess(ZFYCameraStatus zFYCameraStatus2) {
                        ZFYCamera1Helper.this.openLock.set(false);
                        ZFYCamera1Helper.this.updateCameraStream(zFYCameraStatus2.isPreviewing(), zFYCameraStatus2.isRecording(), zFYCameraStatus2.isRemoteing());
                    }
                });
                return;
            }
        }
        statusChange(3);
        this.openLock.set(false);
    }
}
